package com.itboye.ihomebank.util;


import com.itboye.ihomebank.R;

import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.TextView;

/**
 * 更改头像 ，调用相机和相册
 *
 */
public class WriteZhangHaoPopupWindow extends PopupWindow {
	private Button btn_ok, btn_cancel;
	EditText pass;
	private View cameraMenuView;

	@SuppressWarnings("deprecation")
	public WriteZhangHaoPopupWindow(Activity context, OnClickListener itemOnclick) {
		super(context);
		LayoutInflater layoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		cameraMenuView = layoutInflater.inflate(R.layout.dialog_write_zhanghao,
				null);
		btn_ok = (Button) cameraMenuView.findViewById(R.id.btn_ok);
		btn_cancel = (Button) cameraMenuView.findViewById(R.id.btn_cancel);
		pass = (EditText) cameraMenuView
				.findViewById(R.id.pass);

		btn_cancel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				dismiss();
			}
		});
		btn_ok.setOnClickListener(itemOnclick);
		btn_cancel.setOnClickListener(itemOnclick);
		this.setContentView(cameraMenuView);
		this.setWidth(LayoutParams.FILL_PARENT);
		this.setHeight(LayoutParams.WRAP_CONTENT);
		this.setFocusable(true);
//		this.setAnimationStyle(R.style.AnimBottom);
		ColorDrawable dw = new ColorDrawable(0xb000000);
		this.setBackgroundDrawable(dw);
		cameraMenuView.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
//				int height = cameraMenuView.findViewById(R.id.camera_layout)
//						.getTop();
//				int y = (int) event.getY();
//				if (event.getAction() == MotionEvent.ACTION_UP) {
//					if (y < height) {
//						dismiss();
//					}
//				}

				return true;
			}
		});
	}
}
